package com.ly.springsolrtest.springsolr.dao;

import com.ly.springsolrtest.springsolr.bo.ArticleBo;

import org.springframework.data.domain.Pageable;
import org.springframework.data.solr.core.query.result.HighlightPage;
import org.springframework.data.solr.repository.Highlight;
import org.springframework.data.solr.repository.Query;
import org.springframework.data.solr.repository.SolrCrudRepository;



public interface ArticleBoSolrJpaDao extends SolrCrudRepository<ArticleBo, String> {
    /**
     * 分页查询，高亮
     *
     * @param [keyword, pageable]
     * @return org.springframework.data.solr.core.query.result.HighlightPage<com.ly.springsolrtest.springsolr.bo.ArticleBo>
     * @author linweijian
     * @date 2018/3/30 13:34
     */
    @Query("name:?1 or content:?1")
    @Highlight(prefix = "<font color='red'>", postfix = "</font",fragsize = 0)
    HighlightPage<ArticleBo> findArticleBoByKeywords(String keyword, Pageable pageable);

    /**
     * 根据Id查找文章
     *
     * @param [id]
     * @return com.ly.springsolrtest.springsolr.bo.ArticleBo
     * @author linweijian
     * @date 2018/3/30 13:24
     */
    ArticleBo getById(String id);

    /**
     * 根据Id删除文章
     *
     * @param [id]
     * @return void
     * @author linweijian
     * @date 2018/3/30 13:27
     */
    void deleteById(String id);

}
